from llama_index.core.vector_stores import SimpleVectorStore
from llama_index.core.schema import  TextNode
from llama_index.core import Settings
from llama_index.embeddings.zhipuai import ZhipuAIEmbedding
from llama_index.graph_stores.neo4j import Neo4jGraphStore


embed_model = ZhipuAIEmbedding(
    model="embedding-2",
    api_key="f387f5e4837d4e4bba6d267682a957c9.PmPiTw8qVlsI2Oi5"
    # With the `embedding-3` class
    # of models, you can specify the size
    # of the embeddings you want returned.
    # dimensions=1024
)
Settings.embed_model=embed_model

'''

docker run   -p 7474:7474 -p 7687:7687  -v $PWD/data:/data -v $PWD/plugins:/plugins  --name neo4j-apoc    -e NEO4J_apoc_export_file_enabled=true   -e NEO4J_apoc_import_file_enabled=true  -e NEO4J_apoc_import_file_use__neo4j__config=true   -e NEO4JLABS_PLUGINS=\[\"apoc\"\]    neo4j:latest

'''

text="""金秋十月，中华人民共和国迎来76周年华诞。每逢国庆，无论身处何地，爱国主义情愫都会引发中华儿女心中的共鸣。
爱国，是人世间最深层、最持久的情感，是每一个中国人的心之所系、情之所归。"""

node = TextNode(text=text, metadata={"title": "金秋十月"})
node.embedding=embed_model.get_text_embedding(text)

from llama_index.core.graph_stores.types import EntityNode, ChunkNode, Relation
'''https://github.com/vesoft-inc/nebula-studio'''
# Create a two entity nodes
entity1 = EntityNode(label="PERSON", name="Logan", properties={"age": 28})
entity2 = EntityNode(label="ORGANIZATION", name="LlamaIndex")

# Create a relation
relation = Relation(
    label="WORKS_FOR",
    source_id=entity1.id,
    target_id=entity2.id,
    properties={"since": 2023},
)

from llama_index.graph_stores.nebula import NebulaPropertyGraphStore

graph_store = NebulaPropertyGraphStore(

    space="llamaindex_nebula_property_graph", overwrite=True
)


graph_store.upsert_nodes([entity1, entity2])
graph_store.upsert_relations([relation])
